<extend name="public@base5"/>
<block name="head">
    <include file="plugin/functions"/>
</block>
<block name="main">
    <div class="wrap">
        <form method="put" class="form-horizontal js-ajax-form" action="admin/plugins/{$id}/config">
            <empty name="custom_config">
                {:_parse_plugin_config($data['config'])}
                <else/>
                <present name="custom_config">
                    {$custom_config}
                </present>
            </empty>
            <div class="row mb-3">
                <div class="offset-md-2 col-sm-10">
                    <input type="hidden" name="id" value="{$id}" readonly>
                    <button type="submit" class="btn btn-primary js-ajax-submit" data-refresh="0">
                        <i class="fa fa-save fa-fw"></i> {:lang('SAVE')}
                    </button>
                </div>
            </div>
        </form>
    </div>
</block>
<block name="scripts">
    <script>
        Wind.use('colorpicker', function () {
            $('.js-color').each(function () {
                var $this = $(this);
                $this.ColorPicker({
                    livePreview: true,
                    onChange: function (hsb, hex, rgb) {
                        $this.val('#' + hex);
                    },
                    onBeforeShow: function () {
                        $(this).ColorPickerSetColor(this.value);
                    }
                });
            });

        });

        function doSelectLocation(obj) {
            var $obj = $(obj);
            var title = $obj.data('title');
            var $realInput = $obj;
            var location = $realInput.val();

            parent.openIframeLayer(
                "{:url('dialog/map')}?location=" + location,
                title,
                {
                    area: GV.IS_MOBILE ? ['100%', '100%'] : ['700px', '90%'],
                    offset: GV.IS_MOBILE ? ['0px', '0px'] : 'auto',
                    btn: ["{:lang('OK')}", "{:lang('Cancel')}"],
                    yes: function (index, layero) {
                        var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                        var location = iframeWin.confirm();
                        $realInput.val(location.lng + ',' + location.lat);
                        //$obj.val(location.address);
                        parent.layer.close(index); //如果设定了yes回调，需进行手工关闭
                    }
                }
            );
        }
    </script>
</block>